package com.cloud.system.api.mapper;

import com.cloud.system.api.bean.LoginHumanSuggest;
import com.cloud.system.common.utils.BaseMapperHelper;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface LoginHumanSuggestMapper extends BaseMapperHelper<LoginHumanSuggest> {

    @Select("select human_info.user_name from human_info,unit_info where human_info.delete_flag = 0 and human_info.user_name like #{value} " +
            "and human_info.unit_id = unit_info.unit_id order by unit_info.unit_level asc")
    @ResultMap("BaseResultMap")
    List<LoginHumanSuggest> selectlistPage(@Param("value")String value);


    @Select("SELECT human_info.user_name, human_info.human_type, t.unit_type_id, t.subject_name FROM human_info, (select unit_info.unit_id, unit_info.subject_name, unit_info.unit_type_id, unit_info.display_order from unit_info where unit_code like " +
            "( SELECT concat( unit_code, '%' ) unit_code FROM unit_info WHERE region_code = #{code} AND delete_flag != 1 AND unit_type_id = '0' ) ) t WHERE human_info.delete_flag != 1  AND human_info.user_name LIKE #{value} AND human_info.unit_id = t.unit_id" +
            " ORDER BY human_info.unit_code, human_info.human_type ASC")
    @Results({@Result(property = "userName", column = "user_name"),
            @Result(property = "humanType", column = "human_type"),
            @Result(property = "unitTypeId", column = "unit_type_id"),
            @Result(property = "subjectName", column = "subject_name")})
    List<LoginHumanSuggest> selectOptionlist(@Param("value")String value, @Param("code")String code);
}
